#include <ros/ros.h>
#include <sensor_msgs/PointCloud2.h>
#include <pcl_conversions/pcl_conversions.h>
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>


int main (int argc, char** argv)
{

  ros::init(argc, argv, "pcl_rviz");

  sensor_msgs::PointCloud2 output;

  pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGB>);

  pcl::io::loadPCDFile<pcl::PointXYZRGB> ("/home/joker/Desktop/point_cloud/3.pcd", *cloud);

  pcl::toROSMsg(*cloud, output);

  ros::NodeHandle nh;

  ros::Publisher pub = nh.advertise<sensor_msgs::PointCloud2> ("output", 1);

  output.header.frame_id = "hh";

  ros::Rate loop_rate(1);

  while(ros::ok())
  {
      pub.publish (output);
      loop_rate.sleep();
  }

  ros::spin ();
}